package com.government.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.government.common.annotation.Log;
import com.government.common.core.controller.BaseController;
import com.government.common.core.domain.AjaxResult;
import com.government.common.enums.BusinessType;
import com.government.system.domain.WebUrl;
import com.government.system.service.IWebUrlService;
import com.government.common.utils.poi.ExcelUtil;
import com.government.common.core.page.TableDataInfo;

/**
 * 网站地址Controller
 * 
 * @author system
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/system/web")
public class WebUrlController extends BaseController
{
    @Autowired
    private IWebUrlService webUrlService;

    /**
     * 查询网站地址列表
     */
    @PreAuthorize("@ss.hasPermi('system:web:list')")
    @GetMapping("/list")
    public TableDataInfo list(WebUrl webUrl)
    {
        startPage();
        List<WebUrl> list = webUrlService.selectWebUrlList(webUrl);
        return getDataTable(list);
    }

    /**
     * 导出网站地址列表
     */
    @PreAuthorize("@ss.hasPermi('system:web:export')")
    @Log(title = "网站地址", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WebUrl webUrl)
    {
        List<WebUrl> list = webUrlService.selectWebUrlList(webUrl);
        ExcelUtil<WebUrl> util = new ExcelUtil<WebUrl>(WebUrl.class);
        util.exportExcel(response, list, "网站地址数据");
    }

    /**
     * 获取网站地址详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:web:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(webUrlService.selectWebUrlById(id));
    }

    /**
     * 新增网站地址
     */
    @PreAuthorize("@ss.hasPermi('system:web:add')")
    @Log(title = "网站地址", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WebUrl webUrl)
    {
        return toAjax(webUrlService.insertWebUrl(webUrl));
    }

    /**
     * 修改网站地址
     */
    @PreAuthorize("@ss.hasPermi('system:web:edit')")
    @Log(title = "网站地址", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WebUrl webUrl)
    {
        return toAjax(webUrlService.updateWebUrl(webUrl));
    }

    /**
     * 删除网站地址
     */
    @PreAuthorize("@ss.hasPermi('system:web:remove')")
    @Log(title = "网站地址", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(webUrlService.deleteWebUrlByIds(ids));
    }
}
